<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>Sha2 (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>

  <script type="text/javascript" src="//www.google.com/jsapi"></script>
  <script type="text/javascript">
     google.load("visualization", "1", {packages:["orgchart"]});
     var _loadingVisualizations = true;
  </script>

  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
        <span class="fn">crypt.Sha2</span>
        <span>Extends</span>
        <span class="fn-name">
          <a href="class_goog_crypt_Hash.html">
          goog.crypt.Hash
</a>
        </span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    SHA-2 cryptographic hash constructor.
This constructor should not be used directly to create the object. Rather,
one should use the constructor of the sub-classes.

  </div>


        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_crypt_sha2.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/crypt/sha2.js">Git</a></li>
          </ol>
        </div>
</div>






<h2 class="g-first">Inheritance</h2>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
  <tr><td><span class="type"><a href="class_goog_crypt_Hash.html">goog.crypt.Hash</a></span></td><td></td></tr>
  <tr><td>goog.crypt.Sha2</td><td><span class="type"><a href="class_goog_crypt_Hash.html">goog.crypt.Hash</a></span></td></tr>
</table>
</div>
<div class='gviz-org-chart-container goog-inline-block'>
<table class='gviz-org-chart' style='display:none'>
      <tr><td><span class="type"><a href="class_goog_crypt_Sha224.html">goog.crypt.Sha224</a></span></td><td>goog.crypt.Sha2</td></tr>
      <tr><td><span class="type"><a href="class_goog_crypt_Sha256.html">goog.crypt.Sha256</a></span></td><td>goog.crypt.Sha2</td></tr>
  </table>
</div>




  <h2>Constructor</h2>
      <div class="fn-constructor">
    goog.crypt.Sha2(<span></span>)
  </div>



<h2>Instance Methods</h2>


  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_crypt_Sha2.html">
              goog.crypt.Sha2
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.crypt.Sha2.prototype.computeChunk_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">computeChunk_<span class="args">(<span class="arg">chunk</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Helper function to compute the hashes for a given 512-bit message chunk.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">chunk</span>
        : <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;
        <div class="entryOverview">A 512-bit message chunk to be processed.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line125">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.crypt.Sha2.prototype.digest"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">digest<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line241">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.crypt.Sha2.prototype.update"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">update<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line194">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_crypt_Hash.html">
              goog.crypt.Hash
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.crypt.Hash.prototype.digest"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">digest<span class="args">()</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;&nbsp;
            The finalized hash computed
    from the internal accumulator.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_hash.js.source.html#line69">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.crypt.Hash.prototype.update"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryName">update<span class="args">(<span class="arg">bytes</span>,&nbsp;<span class="arg">opt_length</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Adds a byte array (array with values in [0-255] range) or a string (might
only contain 8-bit, i.e., Latin1 characters) to the internal accumulator.

Many hash functions operate on blocks of data and implement optimizations
when a full chunk of data is readily available. Hence it is often preferable
to provide large chunks of data (a kilobyte or more) than to repeatedly
call the update method with few tens of bytes. If this is not possible, or
not feasible, it might be good to provide data in multiplies of hash block
size (often 64 bytes). Please see the implementation and performance tests
of your favourite hash.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">bytes</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&gt;<span>&nbsp;|&nbsp;</span><span class="type">Uint8Array</span><span>&nbsp;|&nbsp;</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">Data used for the update.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_length</span>
        : <span class="type">number=</span>
        <div class="entryOverview">Number of bytes to use.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_hash.js.source.html#line62">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>




<h2>Instance Properties</h2>







<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_crypt_Sha2.html">
              goog.crypt.Sha2
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry protected">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.chunk"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">chunk</span>
        : 
     </div>


     <div class="entryOverview">
       A chunk holding the currently processed message bytes. Once the chunk has
64 bytes, we feed it into computeChunk_ function and reset this.chunk_.
Sub-class needs to reset it when overriding reset().

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line56">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.constructor"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">constructor</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line44">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry protected">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.hash"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">hash</span>
        : 
     </div>


     <div class="entryOverview">
       Holds the previous values of accumulated hash a-h in the computeChunk_
function.
It is a subclass-dependent value. Sub-class needs to explicitly set it
when overriding reset().

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line90">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.inChunk"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">inChunk</span>
        : 
     </div>


     <div class="entryOverview">
       Current number of bytes in this.chunk_.
Sub-class needs to reset it when overriding reset().

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line64">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry protected">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.numHashBlocks"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">numHashBlocks</span>
        : 
     </div>


     <div class="entryOverview">
       The number of output hash blocks (each block is 4 bytes long).
It is a subclass-dependent value. Sub-class needs to explicitly set it
when overriding reset().

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line99">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.pad_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">pad_</span>
        : 
     </div>


     <div class="entryOverview">
       Contains data needed to pad messages less than 64 bytes.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line79">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.reset"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">reset</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line117">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry protected">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.total"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">total</span>
        : 
     </div>


     <div class="entryOverview">
       Total number of bytes in currently processed message.
Sub-class needs to reset it when overriding reset().

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line72">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.prototype.w_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">w_</span>
        : 
     </div>


     <div class="entryOverview">
       Temporary array used in chunk computation.  Allocate here as a
member rather than as a local within computeChunk_() as a
performance optimization to reduce the number of allocations and
reduce garbage collection.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line109">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>

<div>
       <div class="desc">
         Defined in
         <span class="fn-name">
            <a href="class_goog_crypt_Hash.html">
              goog.crypt.Hash
            </a>
         </span>
       </div>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.crypt.Hash.prototype.blockSize"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">blockSize</span>
        : 
     </div>


     <div class="entryOverview">
       The block size for the hasher.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_hash.js.source.html#line37">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.crypt.Hash.prototype.reset"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryName">reset</span>
        : 
     </div>


     <div class="entryOverview">
       Resets the internal accumulator.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_hash.js.source.html#line44">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
</div>










<div class="section">
  <table class="horiz-rule">


  </table>
</div>



<h2>Static Properties</h2>






<div class="section">
  <table class="horiz-rule">


     <tr class="even entry private">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.K_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.crypt.Sha2.</span><span class="entryName">K_</span>
        : 
     </div>


     <div class="entryOverview">
       Constants used in SHA-2.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line275">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.crypt.Sha2.superClass_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.crypt.Sha2.</span><span class="entryName">superClass_</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_crypt_sha2.js.source.html#line44">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package crypt</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="crypt.Sha2"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
